Forum : How to find the selected radio button immediately using the 'this' variable?
Brief description  about Online courses   join in Online courses
View Arun  Desai 's Profile

How to find the selected radio button immediately using the 'this' variable?

hi ,

How to find the selected radio button immediately using the 'this' variable?
Asked by Arun Desai | Nov 27, 2009 |  Reply now
Replies (1)
View teacher siliconindia 's Profile
Hi arun,

Please go through the below code:

<script>
function favAnimal(button) {
alert('You like '+button.value+'s.');
}
</script>
<input type="radio" name="marsupial" value="kangaroo"
onchange="favAnimal(this)">Kangaroo
<br /><input type="radio" name="marsupial" value="Opossum"
onchange="favAnimal(this)">Opossum
<br /><input type="radio" name="marsupial" value="Tasmanian Tiger"
onchange="favAnimal(this)">Tasmanian Tiger
Nov 27, 2009